package com.hmall.api.client;


import com.hmall.api.config.DefaultFeignConfig;
import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import com.hmall.api.fallback.ItemClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

@FeignClient(value = "item-service",configuration = DefaultFeignConfig.class,fallbackFactory = ItemClientFallback.class)
public interface ItemClient {
    @GetMapping("/items")
    List<ItemDTO> queryByItemIds(@RequestParam("ids") Collection<Long> ids);


    @GetMapping("/items/{id}")
    ItemDTO queryItemById(@PathVariable("id") Long id);


    @PutMapping("/items/stock/deduct")
    void deductStock(@RequestBody List<OrderDetailDTO> items);


    @PutMapping("/item/stock/recover")
    void recoverStock(@RequestParam("orderDetailDTOS") List<OrderDetailDTO> orderDetailDTOS);
}


